const express = require('express')

const route = express.Router()

//引入权限校验文件
const isLoginMiddle = require('../middleware/isLoginMiddle')

//引入数据库文件
const addAdvModel = require('../db/model/addAdvModel')


//书写一个接口
route.get('/getUpData', isLoginMiddle, async (req, res) => {
  //获取到id
  const { _id } = req.query
  //去当前数据库查询对应的数据
  try {
    const findResult = await addAdvModel.findOne({
      _id
    })
    //把查询到的值响应给前台
    res.send({
      code: 10000,
      mesage: '更新数据成功',
      data: findResult
    })
  } catch (e) {
    console.log('更新数据错误'+e.message);
    res.send({
      code:10001,
      mesage:"更新数据错误"+e.message,
      data:null
    })
  }
})

module.exports = route